import http from "../../utils/http"

// components/s-search.ts
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    disabled: {
      type: Boolean,
      default: false
    },
    historicalSearch: {
      type: String,
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    q: "",
    passOrNot:true,
    searchResultList: [],
    searchRecords: []
  },

  /**
   * 组件的方法列表
   */
  methods: {
    link() {
      if (this.data.disabled) {
        wx.navigateTo({
          url: '/pages/search/search'
        })
      }
    },
    getSearchValue(e) {
      const { value } = e.detail
      this.setData({
        q: value
      })
    },
    passToParent() {
      let {q} = this.data
      q = q.replace(/(^\s*)|(\s*$)/g, '');
 
      if (q == '' || q == undefined || q == null) {
        this.setData({
          passOrNot:false
        })
      } else {
        this.triggerEvent('searchValue', this.data.q)
      }
    },
  },
})
